package com.evendai.sipdemo

import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import com.evendai.loglibrary.Timber
import com.evendai.sipdemo.sip.audio.IncomingService
import com.evendai.sipdemo.sip.audio.OutgoingService
import org.doubango.ngn.NgnApplication

class App: NgnApplication() {

    override fun onCreate() {
        super.onCreate()
        Timber.init(this, BuildConfig::class.java)
        Thread.setDefaultUncaughtExceptionHandler { t, e ->
            Timber.fe(e, "发生了未捕捉异常")
            stopService(Intent(this, OutgoingService::class.java))
            stopService(Intent(this, IncomingService::class.java))
            Thread.getDefaultUncaughtExceptionHandler()?.uncaughtException(t, e)
        }
    }

    companion object {

        fun getContext(): Context {
            return NgnApplication.getContext()
        }

        fun getVersionName(): String {
            return NgnApplication.getVersionName()
        }

        fun getVersionCode(): Int {
            return NgnApplication.getVersionCode()
        }

        fun getConnectivityManager(): ConnectivityManager {
            return NgnApplication.getConnectivityManager()
        }

    }

}